<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<html>
<head>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>添加用户</title>
<script type="text/javascript">
	$(function($) {
		$('#questionList')
				.datagrid(
						{
							title : '试题列表', //标题
							method : 'post',
							iconCls : 'icon-search', //图标
							singleSelect : false, //多选
							height : 360, //高度
							fitColumns : true, //自动调整各列，用了这个属性，下面各列的宽度值就只是一个比例。
							striped : true, //奇偶行颜色不同
							collapsible : true,//可折叠
							url : "/ExaminationManagementSystem/question/Questions",
							idField : 'tqId', //主键字段
							pagination : true, //显示分页
							rownumbers : true, //显示行号
							columns : [ [ {
								field : 'tqId',
								checkbox : true
							}, {
								field : 'tqContent',
								title : '内容',
								align : 'center',
								width : 100
							}, {
								field : 'tqResult',
								title : '答案',
								align : 'center',
								width : 100
							}, {
								field : 'tqScore',
								title : '分数',
								align : 'center',
								width : 100
							} ] ],
							toolbar : [ {
								text : '导出',
								iconCls : 'icon-add',
								handler : function() {
									importQuestion();
								}
							} ,{
								text : '答题',
								iconCls : 'icon-edit',
								handler : function() {
									selectQuestion();
								}
							}],
							onLoadSuccess : function() {
								$('#questionList').datagrid('clearSelections'); //一定要加上这一句，要不然datagrid会记住之前的选择状态，删除时会出问题
							}
						});
	});

	//重新加载列表
	function refreshList() {
		$('#questionList').datagrid('reload');
	}

	function selectQuestion() {
		var rows = $('#questionList').datagrid('getSelections');
		if (rows.length == 0) {
			$.messager.alert('提示', "请选择你要答题的试题！", 'info');
			return;
		}
		var tqId = "";
		$.each(rows, function(i, n) {
			if (i == 0)
				tqId += n.tqId;
			else
				tqId += "&tqId=" + n.tqId;
		});
		showWindow({
  			title:'更新用户信息',
  			href:'/ExaminationManagementSystem/question/selectAnswer?tqId='+tqId,
  			fitColumns : true,
  			maximized:true
  		});
	}

	function importQuestion() {
		var rows = $('#questionList').datagrid('getSelections');
		if (rows.length == 0) {
			$.messager.alert('提示', "请选择你要导出的试题！", 'info');
			return;
		}
		var tqId = "";
		$.each(rows, function(i, n) {
			if (i == 0)
				tqId += n.tqId;
			else
				tqId += "&tqId=" + n.tqId;
		});
		window.location.href= "/ExaminationManagementSystem/downloadQuestions?tqId="+tqId;
	}
</script>
</head>
<body>
	<div style="padding: 10" id="tabdiv">
		<table id="questionList"></table>
	</div>
</body>
</html>